Content-type: text/html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of IPTABLES</TITLE>
</HEAD><BODY>
<H1>IPTABLES</H1>
Section:  (8)<BR>Updated: Mar 09, 2002<BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
























<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>

iptables - administration tool for IPv4 packet filtering and NAT
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>

<B>iptables [-t table] -[AD] </B>chain rule-specification [options]

<BR>

<B>iptables [-t table] -I </B>chain [rulenum] rule-specification [options]

<BR>

<B>iptables [-t table] -R </B>chain rulenum rule-specification [options]

<BR>

<B>iptables [-t table] -D </B>chain rulenum [options]

<BR>

<B>iptables [-t table] -[LFZ] </B>[chain] [options]

<BR>

<B>iptables [-t table] -N </B>chain

<BR>

<B>iptables [-t table] -X </B>[chain]

<BR>

<B>iptables [-t table] -P </B>chain target [options]

<BR>

<B>iptables [-t table] -E </B>old-chain-name new-chain-name

<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>

<B>Iptables</B>

is used to set up, maintain, and inspect the tables of IP packet
filter rules in the Linux kernel.  Several different tables
may be defined.  Each table contains a number of built-in
chains and may also contain user-defined chains.
<P>
Each chain is a list of rules which can match a set of packets.  Each
rule specifies what to do with a packet that matches.  This is called
a `target', which may be a jump to a user-defined chain in the same
table.
<P>
<A NAME="lbAE">&nbsp;</A>
<H2>TARGETS</H2>

A firewall rule specifies criteria for a packet, and a target.  If the
packet does not match, the next rule in the chain is the examined; if
it does match, then the next rule is specified by the value of the
target, which can be the name of a user-defined chain or one of the
special values 
<I>ACCEPT</I>,

<I>DROP</I>,

<I>QUEUE</I>,

or
<I>RETURN</I>.

<P>

<I>ACCEPT </I>

means to let the packet through.
<I>DROP</I>

means to drop the packet on the floor.
<I>QUEUE</I>

means to pass the packet to userspace (if supported by the kernel).
<I>RETURN</I>

means stop traversing this chain and resume at the next rule in the
previous (calling) chain.  If the end of a built-in chain is reached
or a rule in a built-in chain with target
<I>RETURN</I>

is matched, the target specified by the chain policy determines the
fate of the packet.
<A NAME="lbAF">&nbsp;</A>
<H2>TABLES</H2>

There are currently three independent tables (which tables are present
at any time depends on the kernel configuration options and which
modules are present).
<DL COMPACT>
<DT><B>-t, --table </B><I>table</I>

<DD>
This option specifies the packet matching table which the command
should operate on.  If the kernel is configured with automatic module
loading, an attempt will be made to load the appropriate module for
that table if it is not already there.
<P>
The tables are as follows:
<DL COMPACT><DT><DD>
<DL COMPACT>
<DT><B>filter</B>:

<DD>
This is the default table (if no -t option is passed).  It contains
the built-in chains
<B>INPUT</B>

(for packets destined to local sockets),
<B>FORWARD</B>

(for packets being routed through the box), and
<B>OUTPUT</B>

(for locally-generated packets).
<DT><B>nat</B>:

<DD>
This table is consulted when a packet that creates a new
connection is encountered.  It consists of three built-ins:
<B>PREROUTING</B>

(for altering packets as soon as they come in),
<B>OUTPUT</B>

(for altering locally-generated packets before routing), and
<B>POSTROUTING</B>

(for altering packets as they are about to go out).
<DT><B>mangle</B>:

<DD>
This table is used for specialized packet alteration.  Until kernel
2.4.17 it had two built-in chains:
<B>PREROUTING</B>

(for altering incoming packets before routing) and
<B>OUTPUT</B>

(for altering locally-generated packets before routing).
Since kernel 2.4.18, three other built-in chains are also supported:
<B>INPUT</B>

(for packets coming into the box itself),
<B>FORWARD</B>

(for altering packets being routed through the box), and
<B>POSTROUTING</B>

(for altering packets as they are about to go out).
<DT><B>raw</B>:

<DD>
This table is used mainly for configuring exemptions from connection
tracking in combination with the NOTRACK target.  It registers at the netfilter
hooks with higher priority and is thus called before ip_conntrack, or any other
IP tables.  It provides the following built-in chains:
<B>PREROUTING</B>

(for packets arriving via any network interface)
<B>OUTPUT</B>

(for packets generated by local processes)
</DL>
</DL>

</DL>
<A NAME="lbAG">&nbsp;</A>
<H2>OPTIONS</H2>

The options that are recognized by
<B>iptables</B>

can be divided into several different groups.
<A NAME="lbAH">&nbsp;</A>
<H3>COMMANDS</H3>

These options specify the specific action to perform.  Only one of them
can be specified on the command line unless otherwise specified
below.  For all the long versions of the command and option names, you
need to use only enough letters to ensure that
<B>iptables</B>

can differentiate it from all other options.
<DL COMPACT>
<DT><B>-A, --append </B><I>chain rule-specification</I>

<DD>
Append one or more rules to the end of the selected chain.
When the source and/or destination names resolve to more than one
address, a rule will be added for each possible address combination.
<DT><B>-D, --delete </B><I>chain rule-specification</I>

<DD>

<DT><B>-D, --delete </B><I>chain rulenum</I>

<DD>
Delete one or more rules from the selected chain.  There are two
versions of this command: the rule can be specified as a number in the
chain (starting at 1 for the first rule) or a rule to match.
<DT><B>-I, --insert </B><I>chain</I> [<I>rulenum</I>] <I>rule-specification</I>

<DD>
Insert one or more rules in the selected chain as the given rule
number.  So, if the rule number is 1, the rule or rules are inserted
at the head of the chain.  This is also the default if no rule number
is specified.
<DT><B>-R, --replace </B><I>chain rulenum rule-specification</I>

<DD>
Replace a rule in the selected chain.  If the source and/or
destination names resolve to multiple addresses, the command will
fail.  Rules are numbered starting at 1.
<DT><B>-L, --list </B>[<I>chain</I>]

<DD>
List all rules in the selected chain.  If no chain is selected, all
chains are listed.  As every other iptables command, it applies to the
specified table (filter is the default), so NAT rules get listed by
<PRE>
 iptables -t nat -n -L
</PRE>

Please note that it is often used with the
<B>-n</B>

option, in order to avoid long reverse DNS lookups.
It is legal to specify the
<B>-Z</B>

(zero) option as well, in which case the chain(s) will be atomically
listed and zeroed.  The exact output is affected by the other
arguments given. The exact rules are suppressed until you use
<PRE>
 iptables -L -v
</PRE>

<DT><B>-F, --flush </B>[<I>chain</I>]

<DD>
Flush the selected chain (all the chains in the table if none is given).
This is equivalent to deleting all the rules one by one.
<DT><B>-Z, --zero </B>[<I>chain</I>]

<DD>
Zero the packet and byte counters in all chains.  It is legal to
specify the
<B>-L, --list</B>

(list) option as well, to see the counters immediately before they are
cleared. (See above.)
<DT><B>-N, --new-chain </B><I>chain</I>

<DD>
Create a new user-defined chain by the given name.  There must be no
target of that name already.
<DT><B>-X, --delete-chain </B>[<I>chain</I>]

<DD>
Delete the optional user-defined chain specified.  There must be no references
to the chain.  If there are, you must delete or replace the referring
rules before the chain can be deleted.  If no argument is given, it
will attempt to delete every non-builtin chain in the table.
<DT><B>-P, --policy </B><I>chain target</I>

<DD>
Set the policy for the chain to the given target.  See the section
<B>TARGETS</B>

for the legal targets.  Only built-in (non-user-defined) chains can have
policies, and neither built-in nor user-defined chains can be policy
targets.
<DT><B>-E, --rename-chain </B><I>old-chain new-chain</I>

<DD>
Rename the user specified chain to the user supplied name.  This is
cosmetic, and has no effect on the structure of the table.
<DT><B>-h</B>

<DD>
Help.
Give a (currently very brief) description of the command syntax.
</DL>
<A NAME="lbAI">&nbsp;</A>
<H3>PARAMETERS</H3>

The following parameters make up a rule specification (as used in the
add, delete, insert, replace and append commands).
<DL COMPACT>
<DT><B>-p, --protocol </B>[!] <I>protocol</I>

<DD>
The protocol of the rule or of the packet to check.
The specified protocol can be one of
<I>tcp</I>,

<I>udp</I>,

<I>icmp</I>,

or
<I>all</I>,

or it can be a numeric value, representing one of these protocols or a
different one.  A protocol name from /etc/protocols is also allowed.
A &quot;!&quot; argument before the protocol inverts the
test.  The number zero is equivalent to
<I>all</I>.

Protocol
<I>all</I>

will match with all protocols and is taken as default when this
option is omitted.
<DT><B>-s, --source </B>[!] <I>address</I>[/<I>mask</I>]

<DD>
Source specification.
<I>Address</I>

can be either a network name, a hostname (please note that specifying
any name to be resolved with a remote query such as DNS is a really bad idea),
a network IP address (with /mask), or a plain IP address.
The
<I>mask</I>

can be either a network mask or a plain number,
specifying the number of 1's at the left side of the network mask.
Thus, a mask of
<I>24</I>

is equivalent to
<I>255.255.255.0</I>.

A &quot;!&quot; argument before the address specification inverts the sense of
the address. The flag
<B>--src</B>

is an alias for this option.
<DT><B>-d, --destination </B>[!] <I>address</I>[/<I>mask</I>]

<DD>
Destination specification. 
See the description of the
<B>-s</B>

(source) flag for a detailed description of the syntax.  The flag
<B>--dst</B>

is an alias for this option.
<DT><B>-j, --jump </B><I>target</I>

<DD>
This specifies the target of the rule; i.e., what to do if the packet
matches it.  The target can be a user-defined chain (other than the
one this rule is in), one of the special builtin targets which decide
the fate of the packet immediately, or an extension (see
<B>EXTENSIONS</B>

below).  If this
option is omitted in a rule (and
<B>-g</B>

is not used), then matching the rule will have no
effect on the packet's fate, but the counters on the rule will be
incremented.
<DT><B>-g, --goto </B><I>chain</I>

<DD>
This specifies that the processing should continue in a user
specified chain. Unlike the --jump option return will not continue
processing in this chain but instead in the chain that called us via
--jump.
<DT><B>-i, --in-interface </B>[!] <I>name</I>

<DD>
Name of an interface via which a packet was received (only for
packets entering the 
<B>INPUT</B>,

<B>FORWARD</B>

and
<B>PREROUTING</B>

chains).  When the &quot;!&quot; argument is used before the interface name, the
sense is inverted.  If the interface name ends in a &quot;+&quot;, then any
interface which begins with this name will match.  If this option is
omitted, any interface name will match.
<DT><B>-o, --out-interface </B>[!] <I>name</I>

<DD>
Name of an interface via which a packet is going to be sent (for packets
entering the
<B>FORWARD</B>,

<B>OUTPUT</B>

and
<B>POSTROUTING</B>

chains).  When the &quot;!&quot; argument is used before the interface name, the
sense is inverted.  If the interface name ends in a &quot;+&quot;, then any
interface which begins with this name will match.  If this option is
omitted, any interface name will match.
<DT><B>[!]  -f, --fragment</B>

<DD>
This means that the rule only refers to second and further fragments
of fragmented packets.  Since there is no way to tell the source or
destination ports of such a packet (or ICMP type), such a packet will
not match any rules which specify them.  When the &quot;!&quot; argument
precedes the &quot;-f&quot; flag, the rule will only match head fragments, or
unfragmented packets.
<DT><B>-c, --set-counters </B><I>PKTS BYTES</I>

<DD>
This enables the administrator to initialize the packet and byte
counters of a rule (during
<B>INSERT,</B>

<B>APPEND,</B>

<B>REPLACE</B>

operations).
</DL>
<A NAME="lbAJ">&nbsp;</A>
<H3>OTHER OPTIONS</H3>

The following additional options can be specified:
<DL COMPACT>
<DT><B>-v, --verbose</B>

<DD>
Verbose output.  This option makes the list command show the interface
name, the rule options (if any), and the TOS masks.  The packet and
byte counters are also listed, with the suffix 'K', 'M' or 'G' for
1000, 1,000,000 and 1,000,000,000 multipliers respectively (but see
the
<B>-x</B>

flag to change this).
For appending, insertion, deletion and replacement, this causes
detailed information on the rule or rules to be printed.
<DT><B>-n, --numeric</B>

<DD>
Numeric output.
IP addresses and port numbers will be printed in numeric format.
By default, the program will try to display them as host names,
network names, or services (whenever applicable).
<DT><B>-x, --exact</B>

<DD>
Expand numbers.
Display the exact value of the packet and byte counters,
instead of only the rounded number in K's (multiples of 1000)
M's (multiples of 1000K) or G's (multiples of 1000M).  This option is
only relevant for the 
<B>-L</B>

command.
<DT><B>--line-numbers</B>

<DD>
When listing rules, add line numbers to the beginning of each rule,
corresponding to that rule's position in the chain.
<DT><B>--modprobe=command</B>

<DD>
When adding or inserting rules into a chain, use
<B>command</B>

to load any necessary modules (targets, match extensions, etc).
</DL>
<A NAME="lbAK">&nbsp;</A>
<H2>MATCH EXTENSIONS</H2>

iptables can use extended packet matching modules.  These are loaded
in two ways: implicitly, when
<B>-p</B>

or
<B>--protocol</B>

is specified, or with the
<B>-m</B>

or
<B>--match</B>

options, followed by the matching module name; after these, various
extra command line options become available, depending on the specific
module.  You can specify multiple extended match modules in one line,
and you can use the
<B>-h</B>

or
<B>--help</B>

options after the module has been specified to receive help specific
to that module.
<P>
The following are included in the base package, and most of these can
be preceded by a
<B>!</B>

to invert the sense of the match.

<A NAME="lbAL">&nbsp;</A>
<H3>addrtype</H3>

This module matches packets based on their 
<B>address type.</B>

Address types are used within the kernel networking stack and categorize
addresses into various groups.  The exact definition of that group depends on the specific layer three protocol.
<DL COMPACT>
<DT>The following address types are possible:<DD>
<DT><B>UNSPEC</B>

<DD>
an unspecified address (i.e. 0.0.0.0)
<B>UNICAST</B>

an unicast address
<B>LOCAL</B>

a local address
<B>BROADCAST</B>

a broadcast address
<B>ANYCAST</B>

an anycast packet
<B>MULTICAST</B>

a multicast address
<B>BLACKHOLE</B>

a blackhole address
<B>UNREACHABLE</B>

an unreachable address
<B>PROHIBIT</B>

a prohibited address
<B>THROW</B>

FIXME
<B>NAT</B>

FIXME
<B>XRESOLVE</B>

FIXME
<DT><B>--src-type </B><I>type</I>

<DD>
Matches if the source address is of given type
<DT><B>--dst-type </B><I>type</I>

<DD>
Matches if the destination address is of given type
</DL>
<A NAME="lbAM">&nbsp;</A>
<H3>ah</H3>

This module matches the SPIs in AH header of IPSec packets.
<DL COMPACT>
<DT><B>--ahspi </B>[!] <I>spi</I>[:<I>spi</I>]

<DD>
</DL>
<A NAME="lbAN">&nbsp;</A>
<H3>childlevel</H3>

This is an experimental module.  It matches on whether the 
packet is part of a master connection or one of its children (or grandchildren,
etc).  For instance, most packets are level 0.  FTP data transfer is level 1.
<DL COMPACT>
<DT><B>--childlevel </B>[!] <I>level</I>

<DD>
</DL>
<A NAME="lbAO">&nbsp;</A>
<H3>comment</H3>

Allows you to add comments (up to 256 characters) to any rule.
<DL COMPACT>
<DT><B>--comment </B><I>comment</I>

<DD>
<DT>Example:<DD>
iptables -A INPUT -s 192.168.0.0/16 -m comment --comment &quot;A privatized IP block&quot;
</DL>
<A NAME="lbAP">&nbsp;</A>
<H3>condition</H3>

This matches if a specific /proc filename is '0' or '1'.
<DL COMPACT>
<DT><B>--condition </B><I>[!] filename</I>

<DD>
Match on boolean value stored in /proc/net/ipt_condition/filename file
</DL>
<A NAME="lbAQ">&nbsp;</A>
<H3>connmark</H3>

This module matches the netfilter mark field associated with a connection
(which can be set using the
<B>CONNMARK</B>

target below).
<DL COMPACT>
<DT><B>--mark </B><I>value[/mask]</I>

<DD>
Matches packets in connections with the given mark value (if a mask is
specified, this is logically ANDed with the mark before the
comparison).
</DL>
<A NAME="lbAR">&nbsp;</A>
<H3>connrate</H3>

This module matches the current transfer rate in a connection.
<DL COMPACT>
<DT><B>--connrate </B><I>[!] [from</I>]:[<I>to</I>]

<DD>
Match against the current connection transfer rate being within 'from'
and 'to' bytes per second. When the &quot;!&quot; argument is used before the
range, the sense of the match is inverted.
</DL>
<A NAME="lbAS">&nbsp;</A>
<H3>conntrack</H3>

This module, when combined with connection tracking, allows access to
more connection tracking information than the &quot;state&quot; match.
(this module is present only if iptables was compiled under a kernel
supporting this feature)
<DL COMPACT>
<DT><B>--ctstate </B><I>state</I>

<DD>
Where state is a comma separated list of the connection states to
match.  Possible states are
<B>INVALID</B>

meaning that the packet is associated with no known connection,
<B>ESTABLISHED</B>

meaning that the packet is associated with a connection which has seen
packets in both directions,
<B>NEW</B>

meaning that the packet has started a new connection, or otherwise
associated with a connection which has not seen packets in both
directions, and
<B>RELATED</B>

meaning that the packet is starting a new connection, but is
associated with an existing connection, such as an FTP data transfer,
or an ICMP error.
<B>SNAT</B>

A virtual state, matching if the original source address differs from
the reply destination.
<B>DNAT</B>

A virtual state, matching if the original destination differs from the
reply source.
<DT><B>--ctproto </B><I>proto</I>

<DD>
Protocol to match (by number or name)
<DT><B>--ctorigsrc </B><I>[!] address</I>[/<I>mask</I>]

<DD>
Match against original source address
<DT><B>--ctorigdst </B><I>[!] address</I>[/<I>mask</I>]

<DD>
Match against original destination address
<DT><B>--ctreplsrc </B><I>[!] address</I>[/<I>mask</I>]

<DD>
Match against reply source address
<DT><B>--ctrepldst </B><I>[!] address</I><B>[/</B><I>mask</I>]

<DD>
Match against reply destination address
<DT><B>--ctstatus </B><I>[NONE|EXPECTED|SEEN_REPLY|ASSURED</I>][,...]

<DD>
Match against internal conntrack states
<DT><B>--ctexpire </B><I>time</I>[<I>:time</I>]

<DD>
Match remaining lifetime in seconds against given value
or range of values (inclusive)
</DL>
<A NAME="lbAT">&nbsp;</A>
<H3>dscp</H3>

This module matches the 6 bit DSCP field within the TOS field in the
IP header.  DSCP has superseded TOS within the IETF.
<DL COMPACT>
<DT><B>--dscp </B><I>value</I>

<DD>
Match against a numeric (decimal or hex) value [0-32].
<DT><B>--dscp-class </B><I>DiffServ Class</I>

<DD>
Match the DiffServ class. This value may be any of the
BE, EF, AFxx or CSx classes.  It will then be converted
into it's according numeric value.
</DL>
<A NAME="lbAU">&nbsp;</A>
<H3>dstlimit</H3>

This module allows you to limit the packet per second (pps) rate on a per
destination IP or per destination port base.  As opposed to the `limit' match,
every destination ip / destination port has it's own limit.
<DL COMPACT>
<DT><B>--dstlimit </B><I>avg</I>

<DD>
Maximum average match rate (packets per second unless followed by /sec /minute /hour /day postfixes).
<DT><B>--dstlimit-mode </B><I>mode</I>

<DD>
The limiting hashmode.  Is the specified limit per
<B>dstip, dstip-dstport</B>

tuple, 
<B>srcip-dstip</B>

tuple, or per
<B>srcipdstip-dstport</B>

tuple.
<DT><B>--dstlimit-name </B><I>name</I>

<DD>
Name for /proc/net/ipt_dstlimit/* file entry
<DT><B>[</B><I>--dstlimit-burst </I><B>burst</B><I>]</I>

<DD>
Number of packets to match in a burst.  Default: 5
<DT><B>[</B><I>--dstlimit-htable-size </I><B>size</B><I>]</I>

<DD>
Number of buckets in the hashtable
<DT><B>[</B><I>--dstlimit-htable-max </I><B>max</B><I>]</I>

<DD>
Maximum number of entries in the hashtable
<DT><B>[</B><I>--dstlimit-htable-gcinterval </I><B>interval</B><I>]</I>

<DD>
Interval between garbage collection runs of the hashtable (in miliseconds).
Default is 1000 (1 second).
<DT><B>[</B><I>--dstlimit-htable-expire </I><B>time</B>

<DD>
After which time are idle entries expired from hashtable (in miliseconds)?
Default is 10000 (10 seconds).
</DL>
<A NAME="lbAV">&nbsp;</A>
<H3>ecn</H3>

This allows you to match the ECN bits of the IPv4 and TCP header.  ECN is the Explicit Congestion Notification mechanism as specified in RFC3168
<DL COMPACT>
<DT><B>--ecn-tcp-cwr</B>

<DD>
This matches if the TCP ECN CWR (Congestion Window Received) bit is set.
<DT><B>--ecn-tcp-ece</B>

<DD>
This matches if the TCP ECN ECE (ECN Echo) bit is set.
<DT><B>--ecn-ip-ect </B><I>num</I>

<DD>
This matches a particular IPv4 ECT (ECN-Capable Transport). You have to specify
a number between `0' and `3'.
</DL>
<A NAME="lbAW">&nbsp;</A>
<H3>esp</H3>

This module matches the SPIs in ESP header of IPSec packets.
<DL COMPACT>
<DT><B>--espspi </B>[!] <I>spi</I>[:<I>spi</I>]

<DD>
</DL>
<A NAME="lbAX">&nbsp;</A>
<H3>fuzzy</H3>

This module matches a rate limit based on a fuzzy logic controller [FLC]
<DL COMPACT>
<DT><B>--lower-limit  number</B>

<DD>
Specifies the lower limit (in packets per second).
<DT><B>--upper-limit </B><I>number</I>

<DD>
Specifies the upper limit (in packets per second).
</DL>
<A NAME="lbAY">&nbsp;</A>
<H3>geoip</H3>

Match a packet by its source or destination country.
<DL COMPACT>
<DT>[<B>!</B>] <B>--src-cc</B>, <B>--source-country </B><I>country</I>[<B>,</B><I>country</I><B>,</B><I>country</I><B>,</B><I>...</I>]<DD>
Match packet coming from (one of) the specified country(ies)
<DT>[<B>!</B>] <B>--dst-cc</B>, <B>--destination-country </B><I>country</I>[<B>,</B><I>country</I><B>,</B><I>country</I><B>,</B><I>...</I>]<DD>
Match packet going to (one of) the specified country(ies)
<DT>NOTE:<DD>
The country is inputed by its ISO3166 code.

The only extra files you need is a binary db (geoipdb.bin) &amp; its index file (geoipdb.idx).
Both files are generated from a countries &amp; subnets database with the csv2bin tool,
available at <A HREF="http://www.cookinglinux.org">www.cookinglinux.org</A>/geoip/. Both files MUST also be moved in /var/geoip/
as the shared library is statically looking for that pathname (ex.: /var/geoip/geoipdb.bin).
</DL>
<A NAME="lbAZ">&nbsp;</A>
<H3>helper</H3>

This module matches packets related to a specific conntrack-helper.
<DL COMPACT>
<DT><B>--helper </B><I>string</I>

<DD>
Matches packets related to the specified conntrack-helper.
<DL COMPACT><DT><DD>
<P>

string can be &quot;ftp&quot; for packets related to a ftp-session on default port.
For other ports append -portnr to the value, ie. &quot;ftp-2121&quot;.
<P>

Same rules apply for other conntrack-helpers.
</DL>

</DL>
<A NAME="lbBA">&nbsp;</A>
<H3>icmp</H3>

This extension is loaded if `--protocol icmp' is specified.  It
provides the following option:
<DL COMPACT>
<DT><B>--icmp-type </B>[!] <I>typename</I>

<DD>
This allows specification of the ICMP type, which can be a numeric
ICMP type, or one of the ICMP type names shown by the command
<PRE>
 iptables -p icmp -h
</PRE>

</DL>
<A NAME="lbBB">&nbsp;</A>
<H3>ipp2p</H3>

This module matches certain packets in P2P flows. It is not
designed to match all packets belonging to a P2P connection - 
use IPP2P together with CONNMARK for this purpose. Also visit
<A HREF="http://www.ipp2p.org">http://www.ipp2p.org</A> for detailed information.
<P>
Use it together with -p tcp or -p udp to search these protocols
only or without -p switch to search packets of both protocols.
<P>
IPP2P provides the following options:
<DL COMPACT>
<DT><B>--edk </B>

<DD>
Matches as many eDonkey/eMule packets as possible.
<DT><B>--kazaa </B>

<DD>
Matches as many KaZaA packets as possible.
<DT><B>--gnu </B>

<DD>
Matches as many Gnutella packets as possible.
<DT><B>--dc </B>

<DD>
Matches as many Direct Connect packets as possible.
<DT><B>--bit </B>

<DD>
Matches BitTorrent packets.
<DT><B>--apple </B>

<DD>
Matches AppleJuice packets.
<DT><B>--soul </B>

<DD>
Matches some SoulSeek packets. Considered as beta, use careful!
<DT><B>--winmx </B>

<DD>
Matches some WinMX packets. Considered as beta, use careful!
<DT><B>--ares </B>

<DD>
Matches Ares and AresLite packets. Use together with -j DROP only.
<DT><B>--ipp2p </B>

<DD>
Short hand for: --edk --kazaa --gnu --dc
<DT><B>--debug </B>

<DD>
Prints some information about each hit into kernel logfile. May 
produce huge logfiles so beware!
</DL>
<A NAME="lbBC">&nbsp;</A>
<H3>iprange</H3>

This matches on a given arbitrary range of IPv4 addresses
<DL COMPACT>
<DT><B>[!]</B><I>--src-range </I><B>ip-ip</B>

<DD>
Match source IP in the specified range.
<DT><B>[!]</B><I>--dst-range </I><B>ip-ip</B>

<DD>
Match destination IP in the specified range.
</DL>
<A NAME="lbBD">&nbsp;</A>
<H3>length</H3>

This module matches the length of a packet against a specific value
or range of values.
<DL COMPACT>
<DT><B>--length </B><I>length</I>[:<I>length</I>]

<DD>
</DL>
<A NAME="lbBE">&nbsp;</A>
<H3>limit</H3>

This module matches at a limited rate using a token bucket filter.
A rule using this extension will match until this limit is reached
(unless the `!' flag is used).  It can be used in combination with the
<B>LOG</B>

target to give limited logging, for example.
<DL COMPACT>
<DT><B>--limit </B><I>rate</I>

<DD>
Maximum average matching rate: specified as a number, with an optional
`/second', `/minute', `/hour', or `/day' suffix; the default is
3/hour.
<DT><B>--limit-burst </B><I>number</I>

<DD>
Maximum initial number of packets to match: this number gets
recharged by one every time the limit specified above is not reached,
up to this number; the default is 5.
</DL>
<A NAME="lbBF">&nbsp;</A>
<H3>mac</H3>

<DL COMPACT>
<DT><B>--mac-source </B>[!] <I>address</I>

<DD>
Match source MAC address.  It must be of the form XX:XX:XX:XX:XX:XX.
Note that this only makes sense for packets coming from an Ethernet device
and entering the
<B>PREROUTING</B>,

<B>FORWARD</B>

or
<B>INPUT</B>

chains.
</DL>
<A NAME="lbBG">&nbsp;</A>
<H3>mark</H3>

This module matches the netfilter mark field associated with a packet
(which can be set using the
<B>MARK</B>

target below).
<DL COMPACT>
<DT><B>--mark </B><I>value</I>[/<I>mask</I>]

<DD>
Matches packets with the given unsigned mark value (if a mask is
specified, this is logically ANDed with the mask before the
comparison).
</DL>
<A NAME="lbBH">&nbsp;</A>
<H3>mport</H3>

This module matches a set of source or destination ports.  Up to 15
ports can be specified.  It can only be used in conjunction with
<B>-p tcp</B>

or
<B>-p udp</B>.

<DL COMPACT>
<DT><B>--source-ports </B><I>port</I>[,<I>port</I>[,<I>port</I>...]]

<DD>
Match if the source port is one of the given ports.  The flag
<B>--sports</B>

is a convenient alias for this option.
<DT><B>--destination-ports </B><I>port</I>[,<I>port</I>[,<I>port</I>...]]

<DD>
Match if the destination port is one of the given ports.  The flag
<B>--dports</B>

is a convenient alias for this option.
<DT><B>--ports </B><I>port</I>[,<I>port</I>[,<I>port</I>...]]

<DD>
Match if the both the source and destination ports are equal to each
other and to one of the given ports.
</DL>
<A NAME="lbBI">&nbsp;</A>
<H3>multiport</H3>

This module matches a set of source or destination ports.  Up to 15
ports can be specified.  It can only be used in conjunction with
<B>-p tcp</B>

or
<B>-p udp</B>.

<DL COMPACT>
<DT><B>--source-ports </B><I>port</I>[,<I>port</I>[,<I>port</I>...]]

<DD>
Match if the source port is one of the given ports.  The flag
<B>--sports</B>

is a convenient alias for this option.
<DT><B>--destination-ports </B><I>port</I>[,<I>port</I>[,<I>port</I>...]]

<DD>
Match if the destination port is one of the given ports.  The flag
<B>--dports</B>

is a convenient alias for this option.
<DT><B>--ports </B><I>port</I>[,<I>port</I>[,<I>port</I>...]]

<DD>
Match if the both the source and destination ports are equal to each
other and to one of the given ports.
</DL>
<A NAME="lbBJ">&nbsp;</A>
<H3>nth</H3>

This module matches every `n'th packet
<DL COMPACT>
<DT><B>--every </B><I>value</I>

<DD>
Match every `value' packet
<DT><B>[</B><I>--counter </I><B>num</B><I>]</I>

<DD>
Use internal counter number `num'.  Default is `0'.
<DT><B>[</B><I>--start </I><B>num</B><I>]</I>

<DD>
Initialize the counter at the number `num' insetad of `0'.  Most between `0'
and `value'-1.
<DT><B>[</B><I>--packet </I><B>num</B><I>]</I>

<DD>
Match on `num' packet.  Most be between `0' and `value'-1.
</DL>
<A NAME="lbBK">&nbsp;</A>
<H3>owner</H3>

This module attempts to match various characteristics of the packet
creator, for locally-generated packets. It is valid in the
<B>INPUT</B>, <B>OUTPUT</B> and <B>POSTROUTING</B> chains, however in the
<B>INPUT</B> chain only TCP and UDP packets can be matched. Also note
that some packets (such as ICMP ping responses) may have no owner, and
hence never match.
<DL COMPACT>
<DT><B>--uid-owner </B><I>userid</I>

<DD>
Matches if the packet was created by a process with the given
effective user id.
<DT><B>--gid-owner </B><I>groupid</I>

<DD>
Matches if the packet was created by a process with the given
effective group id.
<DT><B>--pid-owner </B><I>processid</I>

<DD>
Matches if the packet was created by a process with the given
process id.
<DT><B>--sid-owner </B><I>sessionid</I>

<DD>
Matches if the packet was created by a process in the given session
group.
<DT><B>--cmd-owner </B><I>name</I>

<DD>
Matches if the packet was created by a process with the given command name.
(this option is present only if iptables was compiled under a kernel
supporting this feature)
<DT><B>NOTE: pid, sid and command matching are broken on SMP</B>

<DD>
</DL>
<A NAME="lbBL">&nbsp;</A>
<H3>physdev</H3>

This module matches on the bridge port input and output devices enslaved
to a bridge device. This module is a part of the infrastructure that enables
a transparent bridging IP firewall and is only useful for kernel versions
above version 2.5.44.
<DL COMPACT>
<DT><B>--physdev-in name</B>

<DD>
Name of a bridge port via which a packet is received (only for
packets entering the
<B>INPUT</B>,

<B>FORWARD</B>

and
<B>PREROUTING</B>

chains). If the interface name ends in a &quot;+&quot;, then any
interface which begins with this name will match. If the packet didn't arrive
through a bridge device, this packet won't match this option, unless '!' is used.
<DT><B>--physdev-out name</B>

<DD>
Name of a bridge port via which a packet is going to be sent (for packets
entering the
<B>FORWARD</B>,

<B>OUTPUT</B>

and
<B>POSTROUTING</B>

chains).  If the interface name ends in a &quot;+&quot;, then any
interface which begins with this name will match. Note that in the
<B>nat</B> and <B>mangle</B>

<B>OUTPUT</B>

chains one cannot match on the bridge output port, however one can in the
<B>filter OUTPUT</B>

chain. If the packet won't leave by a bridge device or it is yet unknown what
the output device will be, then the packet won't match this option, unless

<DT><B>--physdev-is-in</B>

<DD>
Matches if the packet has entered through a bridge interface.
<DT><B>--physdev-is-out</B>

<DD>
Matches if the packet will leave through a bridge interface.
<DT><B>--physdev-is-bridged</B>

<DD>
Matches if the packet is being bridged and therefore is not being routed.
This is only useful in the FORWARD and POSTROUTING chains.
</DL>
<A NAME="lbBM">&nbsp;</A>
<H3>pkttype</H3>

This module matches the link-layer packet type.
<DL COMPACT>
<DT><B>--pkt-type </B><I>[unicast</I>|<I>broadcast</I>|<I>multicast</I>]

<DD>
</DL>
<A NAME="lbBN">&nbsp;</A>
<H3>policy</H3>

This modules matches the policy used by IPsec for handling a packet.
<DL COMPACT>
<DT><B>--dir </B><I>in|out</I>

<DD>
Used to select whether to match the policy used for decapsulation or the
policy that will be used for encapsulation.
<B>in</B>

is valid in the
<B>PREROUTING, INPUT and FORWARD</B>

chains,
<B>out</B>

is valid in the
<B>POSTROUTING, OUTPUT and FORWARD</B>

chains.
<DT><B>--pol </B><I>none|ipsec</I>

<DD>
Matches if the packet is subject to IPsec processing.
<DT><B>--strict</B>

<DD>
Selects whether to match the exact policy or match if any rule of
the policy matches the given policy.
<DT><B>--reqid </B><I>id</I>

<DD>
Matches the reqid of the policy rule. The reqid can be specified with
<B><A HREF="/cgi-bin/man/man2html?8+setkey">setkey</A>(8)</B>

using
<B>unique:id</B>

as level.
<DT><B>--spi </B><I>spi</I>

<DD>
Matches the SPI of the SA.
<DT><B>--proto </B><I>ah|esp|ipcomp</I>

<DD>
Matches the encapsulation protocol.
<DT><B>--mode </B><I>tunnel|transport</I>

<DD>
Matches the encapsulation mode.
<DT><B>--tunnel-src </B><I>addr[/mask]</I>

<DD>
Matches the source address of a tunnel. Only valid with --mode tunnel.
<DT><B>--tunnel-dst </B><I>addr[/mask]</I>

<DD>
Matches the destination address of a tunnel. Only valid with --mode tunnel.
<DT><B>--next</B>

<DD>
Start the next element in the policy specification. Can only be used with
--strict
</DL>
<A NAME="lbBO">&nbsp;</A>
<H3>random</H3>

This module randomly matches a certain percentage of all packets.
<DL COMPACT>
<DT><B>--average </B><I>percent</I>

<DD>
Matches the given percentage.  If omitted, a probability of 50% is set. 
</DL>
<A NAME="lbBP">&nbsp;</A>
<H3>realm</H3>

This matches the routing realm.  Routing realms are used in complex routing
setups involving dynamic routing protocols like BGP.
<DL COMPACT>
<DT><B>--realm </B><I>[!]</I><B>value[/mask]</B>

<DD>
Matches a given realm number (and optionally mask).
</DL>
<A NAME="lbBQ">&nbsp;</A>
<H3>set</H3>

This modules macthes IP sets which can be defined by <A HREF="/cgi-bin/man/man2html?8+ipset">ipset</A>(8).
<DL COMPACT>
<DT><B>--set </B>setname flag[,flag...]

<DD>
where flags are
<B>src</B>

and/or
<B>dst</B>

and there can be no more than six of them. Hence the command
<PRE>
 iptables -A FORWARD -m set --set test src,dst
</PRE>

will match packets, for which (depending on the type of the set) the source
address or port number of the packet can be found in the specified set. If 
there is a binding belonging to the mached set element or there is a default 
binding for the given set, then the rule will match the packet only if 
additionally (depending on the type of the set) the destination address or 
port number of the packet can be found in the set according to the binding.
</DL>
<A NAME="lbBR">&nbsp;</A>
<H3>state</H3>

This module, when combined with connection tracking, allows access to
the connection tracking state for this packet.
<DL COMPACT>
<DT><B>--state </B><I>state</I>

<DD>
Where state is a comma separated list of the connection states to
match.  Possible states are
<B>INVALID</B>

meaning that the packet could not be identified for some reason which
includes running out of memory and ICMP errors which don't correspond to any
known connection,
<B>ESTABLISHED</B>

meaning that the packet is associated with a connection which has seen
packets in both directions,
<B>NEW</B>

meaning that the packet has started a new connection, or otherwise
associated with a connection which has not seen packets in both
directions, and
<B>RELATED</B>

meaning that the packet is starting a new connection, but is
associated with an existing connection, such as an FTP data transfer,
or an ICMP error.
</DL>
<A NAME="lbBS">&nbsp;</A>
<H3>tcp</H3>

These extensions are loaded if `--protocol tcp' is specified. It
provides the following options:
<DL COMPACT>
<DT><B>--source-port </B>[!] <I>port</I>[:<I>port</I>]

<DD>
Source port or port range specification. This can either be a service
name or a port number. An inclusive range can also be specified,
using the format
<I>port</I>:<I>port</I>.

If the first port is omitted, &quot;0&quot; is assumed; if the last is omitted,
&quot;65535&quot; is assumed.
If the second port greater then the first they will be swapped.
The flag
<B>--sport</B>

is a convenient alias for this option.
<DT><B>--destination-port </B>[!] <I>port</I>[:<I>port</I>]

<DD>
Destination port or port range specification.  The flag
<B>--dport</B>

is a convenient alias for this option.
<DT><B>--tcp-flags </B>[!] <I>mask</I> <I>comp</I>

<DD>
Match when the TCP flags are as specified.  The first argument is the
flags which we should examine, written as a comma-separated list, and
the second argument is a comma-separated list of flags which must be
set.  Flags are:
<B>SYN ACK FIN RST URG PSH ALL NONE</B>.

Hence the command
<PRE>
 iptables -A FORWARD -p tcp --tcp-flags SYN,ACK,FIN,RST SYN
</PRE>

will only match packets with the SYN flag set, and the ACK, FIN and
RST flags unset.
<DT><B>[!] --syn</B>

<DD>
Only match TCP packets with the SYN bit set and the ACK and RST bits
cleared.  Such packets are used to request TCP connection initiation;
for example, blocking such packets coming in an interface will prevent
incoming TCP connections, but outgoing TCP connections will be
unaffected.
It is equivalent to <B>--tcp-flags SYN,RST,ACK SYN</B>.
If the &quot;!&quot; flag precedes the &quot;--syn&quot;, the sense of the
option is inverted.
<DT><B>--tcp-option </B>[!] <I>number</I>

<DD>
Match if TCP option set.
<DT><B>--mss </B><I>value</I>[:<I>value</I>]

<DD>
Match TCP SYN or SYN/ACK packets with the specified MSS value (or range),
which control the maximum packet size for that connection.
</DL>
<A NAME="lbBT">&nbsp;</A>
<H3>tcpmss</H3>

This matches the TCP MSS (maximum segment size) field of the TCP header.  You can only use this on TCP SYN or SYN/ACK packets, since the MSS is only negotiated during the TCP handshake at connection startup time.
<DL COMPACT>
<DT><B>[!] --mss</B><I> value[:value]</I>

<DD>
Match a given TCP MSS value or range.
</DL>
<A NAME="lbBU">&nbsp;</A>
<H3>time</H3>

This matches if the packet arrival time/date is within a given range. All options are facultative.
<DL COMPACT>
<DT><B> --timestart </B><I>value</I>

<DD>
Match only if it is after `value' (Inclusive, format: HH:MM ; default 00:00).
<DT><B>--timestop  </B><I>value</I>

<DD>
Match only if it is before `value' (Inclusive, format: HH:MM ; default 23:59).
<DT><B>--days </B><I>listofdays</I>

<DD>
Match only if today is one of the given days. (format: Mon,Tue,Wed,Thu,Fri,Sat,Sun ; default everyday)
<DT><B>--datestart </B><I>date</I>

<DD>
Match only if it is after `date' (Inclusive, format: YYYY[:MM[:DD[:hh[:mm[:ss]]]]] ; h,m,s start from 0 ; default to 1970)
<DT><B>--datestop </B><I>date</I>

<DD>
Match only if it is before `date' (Inclusive, format: YYYY[:MM[:DD[:hh[:mm[:ss]]]]] ; h,m,s start from 0 ; default to 2037)
</DL>
<A NAME="lbBV">&nbsp;</A>
<H3>tos</H3>

This module matches the 8 bits of Type of Service field in the IP
header (ie. including the precedence bits).
<DL COMPACT>
<DT><B>--tos </B><I>tos</I>

<DD>
The argument is either a standard name, (use
<BR>

<BR>&nbsp;iptables&nbsp;-m&nbsp;tos&nbsp;-h
<BR>

to see the list), or a numeric value to match.
</DL>
<A NAME="lbBW">&nbsp;</A>
<H3>ttl</H3>

This module matches the time to live field in the IP header.
<DL COMPACT>
<DT><B>--ttl-eq </B><I>ttl</I>

<DD>
Matches the given TTL value.
<DT><B>--ttl-gt </B><I>ttl</I>

<DD>
Matches if TTL is greater than the given TTL value.
<DT><B>--ttl-lt </B><I>ttl</I>

<DD>
Matches if TTL is less than the given TTL value.
</DL>
<A NAME="lbBX">&nbsp;</A>
<H3>udp</H3>

These extensions are loaded if `--protocol udp' is specified.  It
provides the following options:
<DL COMPACT>
<DT><B>--source-port </B>[!] <I>port</I>[:<I>port</I>]

<DD>
Source port or port range specification.
See the description of the
<B>--source-port</B>

option of the TCP extension for details.
<DT><B>--destination-port </B>[!] <I>port</I>[:<I>port</I>]

<DD>
Destination port or port range specification.
See the description of the
<B>--destination-port</B>

option of the TCP extension for details.
</DL>
<A NAME="lbBY">&nbsp;</A>
<H3>unclean</H3>

This module takes no options, but attempts to match packets which seem
malformed or unusual.  This is regarded as experimental.
<A NAME="lbBZ">&nbsp;</A>
<H2>TARGET EXTENSIONS</H2>

iptables can use extended target modules: the following are included
in the standard distribution.

<A NAME="lbCA">&nbsp;</A>
<H3>BALANCE</H3>

This allows you to DNAT connections in a round-robin way over a given range of destination addresses.
<DL COMPACT>
<DT><B>--to-destination </B><I>ipaddr-ipaddr</I>

<DD>
Address range to round-robin over.
</DL>
<A NAME="lbCB">&nbsp;</A>
<H3>CLASSIFY</H3>

This module allows you to set the skb-&gt;priority value (and thus classify the packet into a specific CBQ class).
<DL COMPACT>
<DT><B>--set-class </B><I>MAJOR:MINOR</I>

<DD>
Set the major and minor class value.
</DL>
<A NAME="lbCC">&nbsp;</A>
<H3>CLUSTERIP</H3>

This module allows you to configure a simple cluster of nodes that share
a certain IP and MAC address without an explicit load balancer in front of
them.  Connections are statically distributed between the nodes in this
cluster.
<DL COMPACT>
<DT><B>--new </B>

<DD>
Create a new ClusterIP.  You always have to set this on the first rule
for a given ClusterIP.
<DT><B>--hashmode </B><I>mode</I>

<DD>
Specify the hashing mode.  Has to be one of
<B>sourceip, sourceip-sourceport, sourceip-sourceport-destport</B>

<DT><B>--clustermac </B><I>mac</I>

<DD>
Specify the ClusterIP MAC address.  Has to be a link-layer multicast address
<DT><B>--total-nodes </B><I>num</I>

<DD>
Number of total nodes within this cluster.
<DT><B>--local-node </B><I>num</I>

<DD>
Local node number within this cluster.
<DT><B>--hash-init </B><I>rnd</I>

<DD>
Specify the random seed used for hash initialization.
</DL>
<A NAME="lbCD">&nbsp;</A>
<H3>CONNMARK</H3>

This module sets the netfilter mark value associated with a connection
<DL COMPACT>
<DT><B>--set-mark mark[/mask]</B>

<DD>
Set connection mark. If a mask is specified then only those bits set in the
mask is modified.
<DT><B>--save-mark [--mask mask]</B>

<DD>
Copy the netfilter packet mark value to the connection mark. If a mask
is specified then only those bits are copied.
<DT><B>--restore-mark [--mask mask]</B>

<DD>
Copy the connection mark value to the packet. If a mask is specified
then only those bits are copied. This is only valid in the
<B>mangle</B>

table.
</DL>
<A NAME="lbCE">&nbsp;</A>
<H3>DNAT</H3>

This target is only valid in the
<B>nat</B>

table, in the
<B>PREROUTING</B>

and
<B>OUTPUT</B>

chains, and user-defined chains which are only called from those
chains.  It specifies that the destination address of the packet
should be modified (and all future packets in this connection will
also be mangled), and rules should cease being examined.  It takes one
type of option:
<DL COMPACT>
<DT><B>--to-destination </B><I>ipaddr</I>[-<I>ipaddr</I>][:<I>port</I>-<I>port</I>]

<DD>
which can specify a single new destination IP address, an inclusive
range of IP addresses, and optionally, a port range (which is only
valid if the rule also specifies
<B>-p tcp</B>

or
<B>-p udp</B>).

If no port range is specified, then the destination port will never be
modified.
<DL COMPACT><DT><DD>
<P>

You can add several --to-destination options.  If you specify more
than one destination address, either via an address range or multiple
--to-destination options, a simple round-robin (one after another in
cycle) load balancing takes place between these adresses.
</DL>
</DL>
<A NAME="lbCF">&nbsp;</A>
<H3>DSCP</H3>

This target allows to alter the value of the DSCP bits within the TOS
header of the IPv4 packet.  As this manipulates a packet, it can only
be used in the mangle table.
<DL COMPACT>
<DT><B>--set-dscp </B><I>value</I>

<DD>
Set the DSCP field to a numerical value (can be decimal or hex)
<DT><B>--set-dscp-class </B><I>class</I>

<DD>
Set the DSCP field to a DiffServ class.
</DL>
<A NAME="lbCG">&nbsp;</A>
<H3>ECN</H3>

This target allows to selectively work around known ECN blackholes.
It can only be used in the mangle table.
<DL COMPACT>
<DT><B>--ecn-tcp-remove</B>

<DD>
Remove all ECN bits from the TCP header.  Of course, it can only be used
in conjunction with
<B>-p tcp</B>.

</DL>
<A NAME="lbCH">&nbsp;</A>
<H3>LOG</H3>

Turn on kernel logging of matching packets.  When this option is set
for a rule, the Linux kernel will print some information on all
matching packets (like most IP header fields) via the kernel log
(where it can be read with
<I>dmesg</I>

or 
<I><A HREF="/cgi-bin/man/man2html?8+syslogd">syslogd</A></I>(8)).

This is a &quot;non-terminating target&quot;, i.e. rule traversal continues at
the next rule.  So if you want to LOG the packets you refuse, use two
separate rules with the same matching criteria, first using target LOG
then DROP (or REJECT).
<DL COMPACT>
<DT><B>--log-level </B><I>level</I>

<DD>
Level of logging (numeric or see <I><A HREF="/cgi-bin/man/man2html?5+syslog.conf">syslog.conf</A></I>(5)).
<DT><B>--log-prefix </B><I>prefix</I>

<DD>
Prefix log messages with the specified prefix; up to 29 letters long,
and useful for distinguishing messages in the logs.
<DT><B>--log-tcp-sequence</B>

<DD>
Log TCP sequence numbers. This is a security risk if the log is
readable by users.
<DT><B>--log-tcp-options</B>

<DD>
Log options from the TCP packet header.
<DT><B>--log-ip-options</B>

<DD>
Log options from the IP packet header.
<DT><B>--log-uid</B>

<DD>
Log the userid of the process which generated the packet.
</DL>
<A NAME="lbCI">&nbsp;</A>
<H3>MARK</H3>

This is used to set the netfilter mark value associated with the
packet.  It is only valid in the
<B>mangle</B>

table.  It can for example be used in conjunction with iproute2.
<DL COMPACT>
<DT><B>--set-mark </B><I>mark</I>

<DD>
</DL>
<A NAME="lbCJ">&nbsp;</A>
<H3>MASQUERADE</H3>

This target is only valid in the
<B>nat</B>

table, in the
<B>POSTROUTING</B>

chain.  It should only be used with dynamically assigned IP (dialup)
connections: if you have a static IP address, you should use the SNAT
target.  Masquerading is equivalent to specifying a mapping to the IP
address of the interface the packet is going out, but also has the
effect that connections are
<I>forgotten</I>

when the interface goes down.  This is the correct behavior when the
next dialup is unlikely to have the same interface address (and hence
any established connections are lost anyway).  It takes one option:
<DL COMPACT>
<DT><B>--to-ports </B><I>port</I>[-<I>port</I>]

<DD>
This specifies a range of source ports to use, overriding the default
<B>SNAT</B>

source port-selection heuristics (see above).  This is only valid
if the rule also specifies
<B>-p tcp</B>

or
<B>-p udp</B>.

</DL>
<A NAME="lbCK">&nbsp;</A>
<H3>MIRROR</H3>

This is an experimental demonstration target which inverts the source
and destination fields in the IP header and retransmits the packet.
It is only valid in the
<B>INPUT</B>,

<B>FORWARD</B>

and
<B>PREROUTING</B>

chains, and user-defined chains which are only called from those
chains.  Note that the outgoing packets are
<B>NOT</B>

seen by any packet filtering chains, connection tracking or NAT, to
avoid loops and other problems.
<A NAME="lbCL">&nbsp;</A>
<H3>NETMAP</H3>

This target allows you to statically map a whole network of addresses onto
another network of addresses.  It can only be used from rules in the
<B>nat</B>

table.
<DL COMPACT>
<DT><B>--to </B><I>address[/mask]</I>

<DD>
Network address to map to.  The resulting address will be constructed in the
following way: All 'one' bits in the mask are filled in from the new `address'.
All bits that are zero in the mask are filled in from the original address.
</DL>
<A NAME="lbCM">&nbsp;</A>
<H3>NOTRACK</H3>

This target disables connection tracking for all packets matching that rule.
<DL COMPACT>
<DT>It can only be used in the<DD>
<B>raw</B>

table.
</DL>
<A NAME="lbCN">&nbsp;</A>
<H3>REDIRECT</H3>

This target is only valid in the
<B>nat</B>

table, in the
<B>PREROUTING</B>

and
<B>OUTPUT</B>

chains, and user-defined chains which are only called from those
chains.  It alters the destination IP address to send the packet to
the machine itself (locally-generated packets are mapped to the
127.0.0.1 address).  It takes one option:
<DL COMPACT>
<DT><B>--to-ports </B><I>port</I>[-<I>port</I>]

<DD>
This specifies a destination port or range of ports to use: without
this, the destination port is never altered.  This is only valid
if the rule also specifies
<B>-p tcp</B>

or
<B>-p udp</B>.

</DL>
<A NAME="lbCO">&nbsp;</A>
<H3>REJECT</H3>

This is used to send back an error packet in response to the matched
packet: otherwise it is equivalent to
<B>DROP</B>

so it is a terminating TARGET, ending rule traversal.
This target is only valid in the
<B>INPUT</B>,

<B>FORWARD</B>

and
<B>OUTPUT</B>

chains, and user-defined chains which are only called from those
chains.  The following option controls the nature of the error packet
returned:
<DL COMPACT>
<DT><B>--reject-with </B><I>type</I>

<DD>
The type given can be
<PRE>
<B> icmp-net-unreachable</B>
<B> icmp-host-unreachable</B>
<B> icmp-port-unreachable</B>
<B> icmp-proto-unreachable</B>
<B> icmp-net-prohibited</B>
<B> icmp-host-prohibited or</B>
<B> icmp-admin-prohibited (*)</B>
</PRE>

which return the appropriate ICMP error message (<B>port-unreachable</B> is
the default).  The option
<B>tcp-reset</B>

can be used on rules which only match the TCP protocol: this causes a
TCP RST packet to be sent back.  This is mainly useful for blocking 
<I>ident</I>

(113/tcp) probes which frequently occur when sending mail to broken mail
hosts (which won't accept your mail otherwise).
<DT>(*) Using icmp-admin-prohibited with kernels that do not support it will result in a plain DROP instead of REJECT<DD>
</DL>
<A NAME="lbCP">&nbsp;</A>
<H3>ROUTE</H3>

This is used to explicitly override the core network stack's routing decision.
<B>mangle</B>

table.
<DL COMPACT>
<DT><B>--oif </B><I>ifname</I>

<DD>
Route the packet through `ifname' network interface
<DT><B>--iif </B><I>ifname</I>

<DD>
Change the packet's incoming interface to `ifname'
<DT><B>--gw </B><I>IP_address</I>

<DD>
Route the packet via this gateway
<DT><B>--continue </B>

<DD>
Behave like a non-terminating target and continue traversing the rules.  Not valid in combination with `--iif' or `--tee'
<DT><B>--tee </B>

<DD>
Make a copy of the packet, and route that copy to the given destination. For the original, uncopied packet, behave like a non-terminating target and continue traversing the rules.  Not valid in combination with `--iif' or `--continue'
</DL>
<A NAME="lbCQ">&nbsp;</A>
<H3>SET</H3>

This modules adds and/or deletes entries from IP sets which can be defined 
by <A HREF="/cgi-bin/man/man2html?8+ipset">ipset</A>(8).
<DL COMPACT>
<DT><B>--add-set </B>setname flag[,flag...]

<DD>
add the address(es)/port(s) of the packet to the sets
<DT><B>--del-set </B>setname flag[,flag...]

<DD>
delete the address(es)/port(s) of the packet from the sets,
where flags are
<B>src</B>

and/or
<B>dst</B>

and there can be no more than six of them.
<DT>The bindings to follow must previously be defined in order to use <DD>
multilevel adding/deleting by the SET target.
</DL>
<A NAME="lbCR">&nbsp;</A>
<H3>SNAT</H3>

This target is only valid in the
<B>nat</B>

table, in the
<B>POSTROUTING</B>

chain.  It specifies that the source address of the packet should be
modified (and all future packets in this connection will also be
mangled), and rules should cease being examined.  It takes one type
of option:
<DL COMPACT>
<DT><B>--to-source  </B><I>ipaddr</I>[-<I>ipaddr</I>][:<I>port</I>-<I>port</I>]

<DD>
which can specify a single new source IP address, an inclusive range
of IP addresses, and optionally, a port range (which is only valid if
the rule also specifies
<B>-p tcp</B>

or
<B>-p udp</B>).

If no port range is specified, then source ports below 512 will be
mapped to other ports below 512: those between 512 and 1023 inclusive
will be mapped to ports below 1024, and other ports will be mapped to
1024 or above. Where possible, no port alteration will occur.
<DL COMPACT><DT><DD>
<P>

You can add several --to-source options.  If you specify more
than one source address, either via an address range or multiple
--to-source options, a simple round-robin (one after another in
cycle) takes place between these adresses.
</DL>
</DL>
<A NAME="lbCS">&nbsp;</A>
<H3>TCPMSS</H3>

This target allows to alter the MSS value of TCP SYN packets, to control
the maximum size for that connection (usually limiting it to your
outgoing interface's MTU minus 40).  Of course, it can only be used
in conjunction with
<B>-p tcp</B>.

<BR>

This target is used to overcome criminally braindead ISPs or servers
which block ICMP Fragmentation Needed packets.  The symptoms of this
problem are that everything works fine from your Linux
firewall/router, but machines behind it can never exchange large
packets:

<DL COMPACT><DT><DD>
<DL COMPACT>
<DT>1)<DD>
Web browsers connect, then hang with no data received.
<DT>2)<DD>
Small mail works fine, but large emails hang.
<DT>3)<DD>
ssh works fine, but scp hangs after initial handshaking.
</DL>
</DL>


Workaround: activate this option and add a rule to your firewall
configuration like:
<PRE>
 iptables -A FORWARD -p tcp --tcp-flags SYN,RST SYN \
             -j TCPMSS --clamp-mss-to-pmtu
</PRE>

<DL COMPACT>
<DT><B>--set-mss </B><I>value</I>

<DD>
Explicitly set MSS option to specified value.
<DT><B>--clamp-mss-to-pmtu</B>

<DD>
Automatically clamp MSS value to (path_MTU - 40).
<DT>These options are mutually exclusive.<DD>
</DL>
<A NAME="lbCT">&nbsp;</A>
<H3>TOS</H3>

This is used to set the 8-bit Type of Service field in the IP header.
It is only valid in the
<B>mangle</B>

table.
<DL COMPACT>
<DT><B>--set-tos </B><I>tos</I>

<DD>
You can use a numeric TOS values, or use
<PRE>
 iptables -j TOS -h
</PRE>

to see the list of valid TOS names.
</DL>
<A NAME="lbCU">&nbsp;</A>
<H3>TRACE</H3>

This target has no options.  It just turns on 
<B>packet tracing</B>

for all packets that match this rule.
<A NAME="lbCV">&nbsp;</A>
<H3>TTL</H3>

This is used to modify the IPv4 TTL header field.  The TTL field determines
how many hops (routers) a packet can traverse until it's time to live is
exceeded.
<DL COMPACT>
<DT>Setting or incrementing the TTL field can potentially be very dangerous,<DD>
so it should be avoided at any cost.  
<DT><B>Don't ever set or increment the value on packets that leave your local network!</B>

<DD>
<B>mangle</B>

table.
<DT><B>--ttl-set </B><I>value</I>

<DD>
Set the TTL value to `value'.
<DT><B>--ttl-dec </B><I>value</I>

<DD>
Decrement the TTL value `value' times.
<DT><B>--ttl-inc </B><I>value</I>

<DD>
Increment the TTL value `value' times.
</DL>
<A NAME="lbCW">&nbsp;</A>
<H3>ULOG</H3>

This target provides userspace logging of matching packets.  When this
target is set for a rule, the Linux kernel will multicast this packet
through a
<I>netlink</I>

socket. One or more userspace processes may then subscribe to various 
multicast groups and receive the packets.
Like LOG, this is a &quot;non-terminating target&quot;, i.e. rule traversal
continues at the next rule.
<DL COMPACT>
<DT><B>--ulog-nlgroup </B><I>nlgroup</I>

<DD>
This specifies the netlink group (1-32) to which the packet is sent.
Default value is 1.
<DT><B>--ulog-prefix </B><I>prefix</I>

<DD>
Prefix log messages with the specified prefix; up to 32 characters
long, and useful for distinguishing messages in the logs.
<DT><B>--ulog-cprange </B><I>size</I>

<DD>
Number of bytes to be copied to userspace.  A value of 0 always copies
the entire packet, regardless of its size.  Default is 0.
<DT><B>--ulog-qthreshold </B><I>size</I>

<DD>
Number of packet to queue inside kernel.  Setting this value to, e.g. 10
accumulates ten packets inside the kernel and transmits them as one
netlink multipart message to userspace.  Default is 1 (for backwards
compatibility).
<BR>

</DL>
<A NAME="lbCX">&nbsp;</A>
<H2>DIAGNOSTICS</H2>

Various error messages are printed to standard error.  The exit code
is 0 for correct functioning.  Errors which appear to be caused by
invalid or abused command line parameters cause an exit code of 2, and
other errors cause an exit code of 1.
<A NAME="lbCY">&nbsp;</A>
<H2>BUGS</H2>

Bugs?  What's this? ;-)
Well... the counters are not reliable on sparc64.
<A NAME="lbCZ">&nbsp;</A>
<H2>COMPATIBILITY WITH IPCHAINS</H2>

This
<B>iptables</B>

is very similar to ipchains by Rusty Russell.  The main difference is
that the chains
<B>INPUT</B>

and
<B>OUTPUT</B>

are only traversed for packets coming into the local host and
originating from the local host respectively.  Hence every packet only
passes through one of the three chains (except loopback traffic, which
involves both INPUT and OUTPUT chains); previously a forwarded packet
would pass through all three.
<P>

The other main difference is that
<B>-i</B>

refers to the input interface;
<B>-o</B>

refers to the output interface, and both are available for packets
entering the
<B>FORWARD</B>

chain.
<P>

<B>iptables </B>

is a pure packet filter when using the default `filter' table, with
optional extension modules.  This should simplify much of the previous
confusion over the combination of IP masquerading and packet filtering
seen previously.  So the following options are handled differently:
<PRE>
 -j MASQ
 -M -S
 -M -L
</PRE>

There are several other changes in iptables.
<A NAME="lbDA">&nbsp;</A>
<H2>SEE ALSO</H2>

<B><A HREF="/cgi-bin/man/man2html?8+iptables-save">iptables-save</A></B>(8),

<B><A HREF="/cgi-bin/man/man2html?8+iptables-restore">iptables-restore</A></B>(8),

<B><A HREF="/cgi-bin/man/man2html?8+ip6tables">ip6tables</A></B>(8),

<B><A HREF="/cgi-bin/man/man2html?8+ip6tables-save">ip6tables-save</A></B>(8),

<B><A HREF="/cgi-bin/man/man2html?8+ip6tables-restore">ip6tables-restore</A></B>(8).


The packet-filtering-HOWTO details iptables usage for
packet filtering, the NAT-HOWTO details NAT,
the netfilter-extensions-HOWTO details the extensions that are
not in the standard distribution,
and the netfilter-hacking-HOWTO details the netfilter internals.
<BR>

See
<B><A HREF="http://www.netfilter.org/">http://www.netfilter.org/</A></B>.

<A NAME="lbDB">&nbsp;</A>
<H2>AUTHORS</H2>

Rusty Russell wrote iptables, in early consultation with Michael
Neuling.
<P>

Marc Boucher made Rusty abandon ipnatctl by lobbying for a generic packet
selection framework in iptables, then wrote the mangle table, the owner match,
the mark stuff, and ran around doing cool stuff everywhere.
<P>

James Morris wrote the TOS target, and tos match.
<P>

Jozsef Kadlecsik wrote the REJECT target.
<P>

Harald Welte wrote the ULOG target, TTL, DSCP, ECN matches and targets.
<P>

The Netfilter Core Team is: Marc Boucher, Martin Josefsson, Jozsef Kadlecsik, 
Patrick McHardy, James Morris, Harald Welte and Rusty Russell.
<P>

Man page written by Herve Eychenne &lt;<A HREF="mailto:rv@wallfire.org">rv@wallfire.org</A>&gt;.




<P>

<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT><A HREF="#lbAB">NAME</A><DD>
<DT><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT><A HREF="#lbAD">DESCRIPTION</A><DD>
<DT><A HREF="#lbAE">TARGETS</A><DD>
<DT><A HREF="#lbAF">TABLES</A><DD>
<DT><A HREF="#lbAG">OPTIONS</A><DD>
<DL>
<DT><A HREF="#lbAH">COMMANDS</A><DD>
<DT><A HREF="#lbAI">PARAMETERS</A><DD>
<DT><A HREF="#lbAJ">OTHER OPTIONS</A><DD>
</DL>
<DT><A HREF="#lbAK">MATCH EXTENSIONS</A><DD>
<DL>
<DT><A HREF="#lbAL">addrtype</A><DD>
<DT><A HREF="#lbAM">ah</A><DD>
<DT><A HREF="#lbAN">childlevel</A><DD>
<DT><A HREF="#lbAO">comment</A><DD>
<DT><A HREF="#lbAP">condition</A><DD>
<DT><A HREF="#lbAQ">connmark</A><DD>
<DT><A HREF="#lbAR">connrate</A><DD>
<DT><A HREF="#lbAS">conntrack</A><DD>
<DT><A HREF="#lbAT">dscp</A><DD>
<DT><A HREF="#lbAU">dstlimit</A><DD>
<DT><A HREF="#lbAV">ecn</A><DD>
<DT><A HREF="#lbAW">esp</A><DD>
<DT><A HREF="#lbAX">fuzzy</A><DD>
<DT><A HREF="#lbAY">geoip</A><DD>
<DT><A HREF="#lbAZ">helper</A><DD>
<DT><A HREF="#lbBA">icmp</A><DD>
<DT><A HREF="#lbBB">ipp2p</A><DD>
<DT><A HREF="#lbBC">iprange</A><DD>
<DT><A HREF="#lbBD">length</A><DD>
<DT><A HREF="#lbBE">limit</A><DD>
<DT><A HREF="#lbBF">mac</A><DD>
<DT><A HREF="#lbBG">mark</A><DD>
<DT><A HREF="#lbBH">mport</A><DD>
<DT><A HREF="#lbBI">multiport</A><DD>
<DT><A HREF="#lbBJ">nth</A><DD>
<DT><A HREF="#lbBK">owner</A><DD>
<DT><A HREF="#lbBL">physdev</A><DD>
<DT><A HREF="#lbBM">pkttype</A><DD>
<DT><A HREF="#lbBN">policy</A><DD>
<DT><A HREF="#lbBO">random</A><DD>
<DT><A HREF="#lbBP">realm</A><DD>
<DT><A HREF="#lbBQ">set</A><DD>
<DT><A HREF="#lbBR">state</A><DD>
<DT><A HREF="#lbBS">tcp</A><DD>
<DT><A HREF="#lbBT">tcpmss</A><DD>
<DT><A HREF="#lbBU">time</A><DD>
<DT><A HREF="#lbBV">tos</A><DD>
<DT><A HREF="#lbBW">ttl</A><DD>
<DT><A HREF="#lbBX">udp</A><DD>
<DT><A HREF="#lbBY">unclean</A><DD>
</DL>
<DT><A HREF="#lbBZ">TARGET EXTENSIONS</A><DD>
<DL>
<DT><A HREF="#lbCA">BALANCE</A><DD>
<DT><A HREF="#lbCB">CLASSIFY</A><DD>
<DT><A HREF="#lbCC">CLUSTERIP</A><DD>
<DT><A HREF="#lbCD">CONNMARK</A><DD>
<DT><A HREF="#lbCE">DNAT</A><DD>
<DT><A HREF="#lbCF">DSCP</A><DD>
<DT><A HREF="#lbCG">ECN</A><DD>
<DT><A HREF="#lbCH">LOG</A><DD>
<DT><A HREF="#lbCI">MARK</A><DD>
<DT><A HREF="#lbCJ">MASQUERADE</A><DD>
<DT><A HREF="#lbCK">MIRROR</A><DD>
<DT><A HREF="#lbCL">NETMAP</A><DD>
<DT><A HREF="#lbCM">NOTRACK</A><DD>
<DT><A HREF="#lbCN">REDIRECT</A><DD>
<DT><A HREF="#lbCO">REJECT</A><DD>
<DT><A HREF="#lbCP">ROUTE</A><DD>
<DT><A HREF="#lbCQ">SET</A><DD>
<DT><A HREF="#lbCR">SNAT</A><DD>
<DT><A HREF="#lbCS">TCPMSS</A><DD>
<DT><A HREF="#lbCT">TOS</A><DD>
<DT><A HREF="#lbCU">TRACE</A><DD>
<DT><A HREF="#lbCV">TTL</A><DD>
<DT><A HREF="#lbCW">ULOG</A><DD>
</DL>
<DT><A HREF="#lbCX">DIAGNOSTICS</A><DD>
<DT><A HREF="#lbCY">BUGS</A><DD>
<DT><A HREF="#lbCZ">COMPATIBILITY WITH IPCHAINS</A><DD>
<DT><A HREF="#lbDA">SEE ALSO</A><DD>
<DT><A HREF="#lbDB">AUTHORS</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 12:42:36 GMT, July 15, 2005
</BODY>
</HTML>
